﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Globalization;
using System.Threading;

namespace MobileSales.Website.Infrastructure
{
    public static class CultureHelper
    {        
        #region GetCurrentCulture
        /// <summary>
        /// Returns currently active culture
        /// </summary>
        /// <returns>Active culture</returns>
        public static CultureInfo GetCurrentCulture()
        {
            try
            {
                string culture = Convert.ToString(HttpContext.Current.Request.Cookies["lang"].Value);
                if (!string.IsNullOrEmpty(culture))
                {
                    return new CultureInfo(culture);
                }
            }
            catch { }

            return Thread.CurrentThread.CurrentCulture;
        }
        #endregion
    }
}
